package com.dcy.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：dcy
 * @Description: University 就是Composite，可以管理College
 * @Date: 2021/1/22 9:48
 */
public class University extends OrganizationComponent {

    List<OrganizationComponent> list = new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        list.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        list.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }

    /**
     *  打印University 包含的学院
     */
    @Override
    protected void print() {
        System.out.println("=============="+getName()+"==============");
        for (OrganizationComponent organizationComponent : list) {
            organizationComponent.print();
        }
    }
}
